package cc.vv.btpartyjob.partymanager.adapter

import android.widget.ProgressBar
import android.widget.TextView
import cc.vv.baselibrary.adapter.SimpleCommonAdapter
import cc.vv.baselibrary.adapter.holder.ExtendViewHolder
import cc.vv.baselibrary.util.LKAppUtil
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.moudel.bean.ReportStatisticsBean

/**
 * 单位报到统计 adapter
 * Created by Chen.qi on 2018/10/24.
 */
class RegisterUnitStatisticsAdapter(layoutResId: Int) : SimpleCommonAdapter<ReportStatisticsBean>(layoutResId) {
    override fun convert(helper: ExtendViewHolder, item: ReportStatisticsBean, position: Int) {

        //统计报到单位名称
        val tvName = helper.getView<TextView>(R.id.tv_irsUnit_communityName)
        val pBView = helper.getView<ProgressBar>(R.id.pb_irsUnit_progressBar)
        val tvAleready = helper.getView<TextView>(R.id.tv_irsUnit_number)
        tvName.text = item.communityName
        var max = 100
        var progress = 1
        if (LKAppUtil.getInstance().isNumeric(item.totalCount)) {
            max = item.totalCount!!.toInt()
        }
        if (LKAppUtil.getInstance().isNumeric(item.reportedCount)) {
            progress = item.reportedCount!!.toInt()
        }
        pBView?.max = max
        pBView?.progress = progress
        tvAleready?.text = item.reportedCount
    }
}